<template>
  <div>
    <div ref="echarts" style="width: 800px; height: 400px;"></div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
export default {
  mounted () {
    this.showLine1()
  },
  methods: {
    showLine1 () {
      const myChart = echarts.init(this.$refs.echarts)
      const option = {
        legend: {},
        tooltip: {},
        // 数据集 有product 而且没有eccode
        dataset: {
          source: [
            ['product', '2012', '2013', '2014', '2015'],
            ['Matcha Latte', 40, 30, 60, 50],
            ['Milk Tea', 86.5, 92.1, 85.7, 83.1],
            ['Cheese Cocoa', 24.1, 67.2, 79.5, 86.4]
          ]
        },
        xAxis: [
          { type: 'category', gridIndex: 0 },
          { type: 'category', gridIndex: 1 }
        ],
        yAxis: [
          { gridIndex: 0 },
          { gridIndex: 1 }
        ],
        grid: [
          { bottom: '55%' },
          { top: '55%' }
        ],
        series: [
          // seriesLayoutBy 要求横拍
          { type: 'bar', seriesLayoutBy: 'row' },
          { type: 'bar', seriesLayoutBy: 'row' },
          { type: 'bar', seriesLayoutBy: 'row' },
          // x轴默认是 下标是0列,不包含product,y轴默认是下标是1列,不包含sales
          { type: 'bar', xAxisIndex: 1, yAxisIndex: 1 },
          { type: 'bar', xAxisIndex: 1, yAxisIndex: 1 },
          { type: 'bar', xAxisIndex: 1, yAxisIndex: 1 },
          { type: 'bar', xAxisIndex: 1, yAxisIndex: 1 }
        ]
      }
      myChart.setOption(option)
    }
  }
}
</script>
<style lang="scss" scoped></style>
